import Vue from 'vue'
import Router from 'vue-router'
import ZhuYe from '@/components/ZhuYe'
import DLogin from '../components/DLogin'/*
import Home from '../components/homepage/Home'
import error from '../components/404'*/

//解决Vue前端的Session问题
import axios from 'axios'
axios.defaults.withCredentials =  true;
// 添加一个响应拦截器，将  res.data -> data
axios.interceptors.response.use(function (response) {
    return response;
}, function (error) {
    return Promise.reject(error);
});


Vue.use(Router)
const createRouter = () => new Router({
    routes: [
        {
            //登录
            path:'/login',
            name:'DLogin',
            component:DLogin,

        },
/*{
    path:'/404',
        name:'error',
    component:error
},*/
//首页
        {
            path: '/zhuYe',
            component: ZhuYe,
            meta: {
                requireAuth: true
            }
        }
    ],

mode:"history"//去掉#

})

const router = createRouter()

export function resetRouter () {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // the relevant part
}

export default router